package com.dhl.substitution.improve;

/**
 * @title: SubstitutionImprove
 * @Author danghailiang
 * @Date: 2022/7/25 11:20
 * @Version 1.0
 */
public class SubstitutionImprove {
    public static void main(String[] args) {
        B b = new B(new  A());
        // 现在实际效果是a+b
        System.out.println(b.fun3(10,5));
        System.out.println(b.fun2(10,5));
        System.out.println(b.fun1(10,5));
    }
}
class Bean{
    public int fun1(int a, int b){
        return a*b;
    }
}

class A{
    public int fun1(int a, int b){
        return a+b;
    }
}

class B extends Bean{

    private A a;

    public B(A a) {
        this.a = a;
    }

    public int fun2(int a, int b){
        return a-b;
    }
    public int fun3(int a, int b){
        return this.a.fun1(a,b);
    }
}